/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package veluanasoft.control;

import java.util.ArrayList;
import java.util.Iterator;
import veluanasoft.modelo.Invoice;
import veluanasoft.modelo.Item;

/**
 *
 * @author Ali Kate
 */
public class InvoiceControl {

    //
    public double totalPrice(Invoice invoice){
        ArrayList<Item> itemList = invoice.arrayItems();
        double totalPrice;
        totalPrice = 0;

        for(Item item : itemList){
            totalPrice += item.getQuantity()*item.getPriceOfWood();
        }

        return totalPrice;
    }

    public double totalDeliveryTime(Invoice invoice){
        ArrayList<Item> itemList = invoice.arrayItems();
        double timeDelivery;
        double partial;
        partial = 0;
        timeDelivery = 0;

        for(Item item : itemList){
            partial = item.getFinalDeliveryTime();
            if(timeDelivery < partial){
                timeDelivery = partial;
            }
        }

        return timeDelivery;
    }
}
